/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */	

var loading_message = 'Loading';

function ag_callService(s_name,params)
{
	if (!params) {
		params = {};
	}

	var log = $('agora_log');
	log.innerHTML += '<div id="loading_icon"><img src="components/com_agora/image/loading.gif" alt="loading"/>'+loading_message+'</div>';
	new Fx.Scroll(log).toBottom();

	params.option = 'com_agora';
	params.task = 'service';
	params.format = 'raw';
	params.action = s_name;

	new Ajax('index.php', {
		method: 'post',
		data: params,
		onFailure: function(){},
		onComplete: function(inResponse) {
			$('loading_icon').remove();
			log.innerHTML += inResponse;
			new Fx.Scroll(log).toBottom();
		}
	}).request();
}

function ag_checkDirs()
{
	ag_callService('checkDirs');
}

function ag_syncUsers()
{
	ag_callService('syncUsers');
}

function ag_recountPosts()
{
	ag_callService('recountPosts');
}

function ag_recountUserPosts()
{
	ag_callService('recountUserPosts');
}

function ag_fixUserDuplication()
{
	ag_callService('fixUserDuplication');
}

function ag_addallUsersToGlobal()
{
	ag_callService('addallUsersToGlobal');
}

function ag_generateHtmlArticles()
{
	ag_callService('generateHtmlArticles');
}

function ag_optimize()
{
	ag_callService('optimize');
}

function ag_installClean(warn)
{
	if (!confirm(warn)) return;

	ag_callService('installClean');
}
